Left Termination of the query pattern fib_in_2(g, a) w.r.t. the given Prolog program could successfully be proven:



Prolog
  ↳ PrologToPiTRSProof

Clauses:

add(0, 0, 0).
add(s(X), Y, s(N)) :- add(X, Y, N).
add(X, s(Y), s(N)) :- add(X, Y, N).
fib(0, 0).
fib(s(0), s(0)).
fib(s(s(X)), N) :- ','(fib(s(X), N1), ','(fib(X, N2), add(N1, N2, N))).

Queries:

fib(g,a).

We use the technique of [30].Transforming Prolog into the following Term Rewriting System:
Pi-finite rewrite system:
The TRS R consists of the following rules:

fib_in(s(s(X)), N) → U3(X, N, fib_in(s(X), N1))
fib_in(s(0), s(0)) → fib_out(s(0), s(0))
fib_in(0, 0) → fib_out(0, 0)
U3(X, N, fib_out(s(X), N1)) → U4(X, N, N1, fib_in(X, N2))
U4(X, N, N1, fib_out(X, N2)) → U5(X, N, add_in(N1, N2, N))
add_in(X, s(Y), s(N)) → U2(X, Y, N, add_in(X, Y, N))
add_in(s(X), Y, s(N)) → U1(X, Y, N, add_in(X, Y, N))
add_in(0, 0, 0) → add_out(0, 0, 0)
U1(X, Y, N, add_out(X, Y, N)) → add_out(s(X), Y, s(N))
U2(X, Y, N, add_out(X, Y, N)) → add_out(X, s(Y), s(N))
U5(X, N, add_out(N1, N2, N)) → fib_out(s(s(X)), N)

The argument filtering Pi contains the following mapping:
fib_in(x1, x2)  =  fib_in(x1)
s(x1)  =  s(x1)
U3(x1, x2, x3)  =  U3(x1, x3)
0  =  0
fib_out(x1, x2)  =  fib_out(x2)
U4(x1, x2, x3, x4)  =  U4(x3, x4)
U5(x1, x2, x3)  =  U5(x3)
add_in(x1, x2, x3)  =  add_in(x1, x2)
U2(x1, x2, x3, x4)  =  U2(x4)
U1(x1, x2, x3, x4)  =  U1(x4)
add_out(x1, x2, x3)  =  add_out(x3)

Infinitary Constructor Rewriting Termination of PiTRS implies Termination of Prolog



↳ Prolog
  ↳ PrologToPiTRSProof
PiTRS
      ↳ DependencyPairsProof

Pi-finite rewrite system:
The TRS R consists of the following rules:

fib_in(s(s(X)), N) → U3(X, N, fib_in(s(X), N1))
fib_in(s(0), s(0)) → fib_out(s(0), s(0))
fib_in(0, 0) → fib_out(0, 0)
U3(X, N, fib_out(s(X), N1)) → U4(X, N, N1, fib_in(X, N2))
U4(X, N, N1, fib_out(X, N2)) → U5(X, N, add_in(N1, N2, N))
add_in(X, s(Y), s(N)) → U2(X, Y, N, add_in(X, Y, N))
add_in(s(X), Y, s(N)) → U1(X, Y, N, add_in(X, Y, N))
add_in(0, 0, 0) → add_out(0, 0, 0)
U1(X, Y, N, add_out(X, Y, N)) → add_out(s(X), Y, s(N))
U2(X, Y, N, add_out(X, Y, N)) → add_out(X, s(Y), s(N))
U5(X, N, add_out(N1, N2, N)) → fib_out(s(s(X)), N)

The argument filtering Pi contains the following mapping:
fib_in(x1, x2)  =  fib_in(x1)
s(x1)  =  s(x1)
U3(x1, x2, x3)  =  U3(x1, x3)
0  =  0
fib_out(x1, x2)  =  fib_out(x2)
U4(x1, x2, x3, x4)  =  U4(x3, x4)
U5(x1, x2, x3)  =  U5(x3)
add_in(x1, x2, x3)  =  add_in(x1, x2)
U2(x1, x2, x3, x4)  =  U2(x4)
U1(x1, x2, x3, x4)  =  U1(x4)
add_out(x1, x2, x3)  =  add_out(x3)


Using Dependency Pairs [1,30] we result in the following initial DP problem:
Pi DP problem:
The TRS P consists of the following rules:

FIB_IN(s(s(X)), N) → U31(X, N, fib_in(s(X), N1))
FIB_IN(s(s(X)), N) → FIB_IN(s(X), N1)
U31(X, N, fib_out(s(X), N1)) → U41(X, N, N1, fib_in(X, N2))
U31(X, N, fib_out(s(X), N1)) → FIB_IN(X, N2)
U41(X, N, N1, fib_out(X, N2)) → U51(X, N, add_in(N1, N2, N))
U41(X, N, N1, fib_out(X, N2)) → ADD_IN(N1, N2, N)
ADD_IN(X, s(Y), s(N)) → U21(X, Y, N, add_in(X, Y, N))
ADD_IN(X, s(Y), s(N)) → ADD_IN(X, Y, N)
ADD_IN(s(X), Y, s(N)) → U11(X, Y, N, add_in(X, Y, N))
ADD_IN(s(X), Y, s(N)) → ADD_IN(X, Y, N)

The TRS R consists of the following rules:

fib_in(s(s(X)), N) → U3(X, N, fib_in(s(X), N1))
fib_in(s(0), s(0)) → fib_out(s(0), s(0))
fib_in(0, 0) → fib_out(0, 0)
U3(X, N, fib_out(s(X), N1)) → U4(X, N, N1, fib_in(X, N2))
U4(X, N, N1, fib_out(X, N2)) → U5(X, N, add_in(N1, N2, N))
add_in(X, s(Y), s(N)) → U2(X, Y, N, add_in(X, Y, N))
add_in(s(X), Y, s(N)) → U1(X, Y, N, add_in(X, Y, N))
add_in(0, 0, 0) → add_out(0, 0, 0)
U1(X, Y, N, add_out(X, Y, N)) → add_out(s(X), Y, s(N))
U2(X, Y, N, add_out(X, Y, N)) → add_out(X, s(Y), s(N))
U5(X, N, add_out(N1, N2, N)) → fib_out(s(s(X)), N)

The argument filtering Pi contains the following mapping:
fib_in(x1, x2)  =  fib_in(x1)
s(x1)  =  s(x1)
U3(x1, x2, x3)  =  U3(x1, x3)
0  =  0
fib_out(x1, x2)  =  fib_out(x2)
U4(x1, x2, x3, x4)  =  U4(x3, x4)
U5(x1, x2, x3)  =  U5(x3)
add_in(x1, x2, x3)  =  add_in(x1, x2)
U2(x1, x2, x3, x4)  =  U2(x4)
U1(x1, x2, x3, x4)  =  U1(x4)
add_out(x1, x2, x3)  =  add_out(x3)
ADD_IN(x1, x2, x3)  =  ADD_IN(x1, x2)
U51(x1, x2, x3)  =  U51(x3)
U31(x1, x2, x3)  =  U31(x1, x3)
U41(x1, x2, x3, x4)  =  U41(x3, x4)
U21(x1, x2, x3, x4)  =  U21(x4)
FIB_IN(x1, x2)  =  FIB_IN(x1)
U11(x1, x2, x3, x4)  =  U11(x4)

We have to consider all (P,R,Pi)-chains

↳ Prolog
  ↳ PrologToPiTRSProof
    ↳ PiTRS
      ↳ DependencyPairsProof
PiDP
          ↳ DependencyGraphProof

Pi DP problem:
The TRS P consists of the following rules:

FIB_IN(s(s(X)), N) → U31(X, N, fib_in(s(X), N1))
FIB_IN(s(s(X)), N) → FIB_IN(s(X), N1)
U31(X, N, fib_out(s(X), N1)) → U41(X, N, N1, fib_in(X, N2))
U31(X, N, fib_out(s(X), N1)) → FIB_IN(X, N2)
U41(X, N, N1, fib_out(X, N2)) → U51(X, N, add_in(N1, N2, N))
U41(X, N, N1, fib_out(X, N2)) → ADD_IN(N1, N2, N)
ADD_IN(X, s(Y), s(N)) → U21(X, Y, N, add_in(X, Y, N))
ADD_IN(X, s(Y), s(N)) → ADD_IN(X, Y, N)
ADD_IN(s(X), Y, s(N)) → U11(X, Y, N, add_in(X, Y, N))
ADD_IN(s(X), Y, s(N)) → ADD_IN(X, Y, N)

The TRS R consists of the following rules:

fib_in(s(s(X)), N) → U3(X, N, fib_in(s(X), N1))
fib_in(s(0), s(0)) → fib_out(s(0), s(0))
fib_in(0, 0) → fib_out(0, 0)
U3(X, N, fib_out(s(X), N1)) → U4(X, N, N1, fib_in(X, N2))
U4(X, N, N1, fib_out(X, N2)) → U5(X, N, add_in(N1, N2, N))
add_in(X, s(Y), s(N)) → U2(X, Y, N, add_in(X, Y, N))
add_in(s(X), Y, s(N)) → U1(X, Y, N, add_in(X, Y, N))
add_in(0, 0, 0) → add_out(0, 0, 0)
U1(X, Y, N, add_out(X, Y, N)) → add_out(s(X), Y, s(N))
U2(X, Y, N, add_out(X, Y, N)) → add_out(X, s(Y), s(N))
U5(X, N, add_out(N1, N2, N)) → fib_out(s(s(X)), N)

The argument filtering Pi contains the following mapping:
fib_in(x1, x2)  =  fib_in(x1)
s(x1)  =  s(x1)
U3(x1, x2, x3)  =  U3(x1, x3)
0  =  0
fib_out(x1, x2)  =  fib_out(x2)
U4(x1, x2, x3, x4)  =  U4(x3, x4)
U5(x1, x2, x3)  =  U5(x3)
add_in(x1, x2, x3)  =  add_in(x1, x2)
U2(x1, x2, x3, x4)  =  U2(x4)
U1(x1, x2, x3, x4)  =  U1(x4)
add_out(x1, x2, x3)  =  add_out(x3)
ADD_IN(x1, x2, x3)  =  ADD_IN(x1, x2)
U51(x1, x2, x3)  =  U51(x3)
U31(x1, x2, x3)  =  U31(x1, x3)
U41(x1, x2, x3, x4)  =  U41(x3, x4)
U21(x1, x2, x3, x4)  =  U21(x4)
FIB_IN(x1, x2)  =  FIB_IN(x1)
U11(x1, x2, x3, x4)  =  U11(x4)

We have to consider all (P,R,Pi)-chains
The approximation of the Dependency Graph [30] contains 2 SCCs with 5 less nodes.

↳ Prolog
  ↳ PrologToPiTRSProof
    ↳ PiTRS
      ↳ DependencyPairsProof
        ↳ PiDP
          ↳ DependencyGraphProof
            ↳ AND
PiDP
                ↳ UsableRulesProof
              ↳ PiDP

Pi DP problem:
The TRS P consists of the following rules:

ADD_IN(X, s(Y), s(N)) → ADD_IN(X, Y, N)
ADD_IN(s(X), Y, s(N)) → ADD_IN(X, Y, N)

The TRS R consists of the following rules:

fib_in(s(s(X)), N) → U3(X, N, fib_in(s(X), N1))
fib_in(s(0), s(0)) → fib_out(s(0), s(0))
fib_in(0, 0) → fib_out(0, 0)
U3(X, N, fib_out(s(X), N1)) → U4(X, N, N1, fib_in(X, N2))
U4(X, N, N1, fib_out(X, N2)) → U5(X, N, add_in(N1, N2, N))
add_in(X, s(Y), s(N)) → U2(X, Y, N, add_in(X, Y, N))
add_in(s(X), Y, s(N)) → U1(X, Y, N, add_in(X, Y, N))
add_in(0, 0, 0) → add_out(0, 0, 0)
U1(X, Y, N, add_out(X, Y, N)) → add_out(s(X), Y, s(N))
U2(X, Y, N, add_out(X, Y, N)) → add_out(X, s(Y), s(N))
U5(X, N, add_out(N1, N2, N)) → fib_out(s(s(X)), N)

The argument filtering Pi contains the following mapping:
fib_in(x1, x2)  =  fib_in(x1)
s(x1)  =  s(x1)
U3(x1, x2, x3)  =  U3(x1, x3)
0  =  0
fib_out(x1, x2)  =  fib_out(x2)
U4(x1, x2, x3, x4)  =  U4(x3, x4)
U5(x1, x2, x3)  =  U5(x3)
add_in(x1, x2, x3)  =  add_in(x1, x2)
U2(x1, x2, x3, x4)  =  U2(x4)
U1(x1, x2, x3, x4)  =  U1(x4)
add_out(x1, x2, x3)  =  add_out(x3)
ADD_IN(x1, x2, x3)  =  ADD_IN(x1, x2)

We have to consider all (P,R,Pi)-chains
For (infinitary) constructor rewriting [30] we can delete all non-usable rules from R.

↳ Prolog
  ↳ PrologToPiTRSProof
    ↳ PiTRS
      ↳ DependencyPairsProof
        ↳ PiDP
          ↳ DependencyGraphProof
            ↳ AND
              ↳ PiDP
                ↳ UsableRulesProof
PiDP
                    ↳ PiDPToQDPProof
              ↳ PiDP

Pi DP problem:
The TRS P consists of the following rules:

ADD_IN(X, s(Y), s(N)) → ADD_IN(X, Y, N)
ADD_IN(s(X), Y, s(N)) → ADD_IN(X, Y, N)

R is empty.
The argument filtering Pi contains the following mapping:
s(x1)  =  s(x1)
ADD_IN(x1, x2, x3)  =  ADD_IN(x1, x2)

We have to consider all (P,R,Pi)-chains
Transforming (infinitary) constructor rewriting Pi-DP problem [30] into ordinary QDP problem [15] by application of Pi.

↳ Prolog
  ↳ PrologToPiTRSProof
    ↳ PiTRS
      ↳ DependencyPairsProof
        ↳ PiDP
          ↳ DependencyGraphProof
            ↳ AND
              ↳ PiDP
                ↳ UsableRulesProof
                  ↳ PiDP
                    ↳ PiDPToQDPProof
QDP
                        ↳ QDPSizeChangeProof
              ↳ PiDP

Q DP problem:
The TRS P consists of the following rules:

ADD_IN(s(X), Y) → ADD_IN(X, Y)
ADD_IN(X, s(Y)) → ADD_IN(X, Y)

R is empty.
Q is empty.
We have to consider all (P,Q,R)-chains.
By using the subterm criterion [20] together with the size-change analysis [32] we have proven that there are no infinite chains for this DP problem.

From the DPs we obtained the following set of size-change graphs:



↳ Prolog
  ↳ PrologToPiTRSProof
    ↳ PiTRS
      ↳ DependencyPairsProof
        ↳ PiDP
          ↳ DependencyGraphProof
            ↳ AND
              ↳ PiDP
PiDP
                ↳ PiDPToQDPProof

Pi DP problem:
The TRS P consists of the following rules:

U31(X, N, fib_out(s(X), N1)) → FIB_IN(X, N2)
FIB_IN(s(s(X)), N) → U31(X, N, fib_in(s(X), N1))
FIB_IN(s(s(X)), N) → FIB_IN(s(X), N1)

The TRS R consists of the following rules:

fib_in(s(s(X)), N) → U3(X, N, fib_in(s(X), N1))
fib_in(s(0), s(0)) → fib_out(s(0), s(0))
fib_in(0, 0) → fib_out(0, 0)
U3(X, N, fib_out(s(X), N1)) → U4(X, N, N1, fib_in(X, N2))
U4(X, N, N1, fib_out(X, N2)) → U5(X, N, add_in(N1, N2, N))
add_in(X, s(Y), s(N)) → U2(X, Y, N, add_in(X, Y, N))
add_in(s(X), Y, s(N)) → U1(X, Y, N, add_in(X, Y, N))
add_in(0, 0, 0) → add_out(0, 0, 0)
U1(X, Y, N, add_out(X, Y, N)) → add_out(s(X), Y, s(N))
U2(X, Y, N, add_out(X, Y, N)) → add_out(X, s(Y), s(N))
U5(X, N, add_out(N1, N2, N)) → fib_out(s(s(X)), N)

The argument filtering Pi contains the following mapping:
fib_in(x1, x2)  =  fib_in(x1)
s(x1)  =  s(x1)
U3(x1, x2, x3)  =  U3(x1, x3)
0  =  0
fib_out(x1, x2)  =  fib_out(x2)
U4(x1, x2, x3, x4)  =  U4(x3, x4)
U5(x1, x2, x3)  =  U5(x3)
add_in(x1, x2, x3)  =  add_in(x1, x2)
U2(x1, x2, x3, x4)  =  U2(x4)
U1(x1, x2, x3, x4)  =  U1(x4)
add_out(x1, x2, x3)  =  add_out(x3)
U31(x1, x2, x3)  =  U31(x1, x3)
FIB_IN(x1, x2)  =  FIB_IN(x1)

We have to consider all (P,R,Pi)-chains
Transforming (infinitary) constructor rewriting Pi-DP problem [30] into ordinary QDP problem [15] by application of Pi.

↳ Prolog
  ↳ PrologToPiTRSProof
    ↳ PiTRS
      ↳ DependencyPairsProof
        ↳ PiDP
          ↳ DependencyGraphProof
            ↳ AND
              ↳ PiDP
              ↳ PiDP
                ↳ PiDPToQDPProof
QDP
                    ↳ QDPSizeChangeProof

Q DP problem:
The TRS P consists of the following rules:

FIB_IN(s(s(X))) → U31(X, fib_in(s(X)))
U31(X, fib_out(N1)) → FIB_IN(X)
FIB_IN(s(s(X))) → FIB_IN(s(X))

The TRS R consists of the following rules:

fib_in(s(s(X))) → U3(X, fib_in(s(X)))
fib_in(s(0)) → fib_out(s(0))
fib_in(0) → fib_out(0)
U3(X, fib_out(N1)) → U4(N1, fib_in(X))
U4(N1, fib_out(N2)) → U5(add_in(N1, N2))
add_in(X, s(Y)) → U2(add_in(X, Y))
add_in(s(X), Y) → U1(add_in(X, Y))
add_in(0, 0) → add_out(0)
U1(add_out(N)) → add_out(s(N))
U2(add_out(N)) → add_out(s(N))
U5(add_out(N)) → fib_out(N)

The set Q consists of the following terms:

fib_in(x0)
U3(x0, x1)
U4(x0, x1)
add_in(x0, x1)
U1(x0)
U2(x0)
U5(x0)

We have to consider all (P,Q,R)-chains.
By using the subterm criterion [20] together with the size-change analysis [32] we have proven that there are no infinite chains for this DP problem.

From the DPs we obtained the following set of size-change graphs: